import { ApiPost, ApiGet } from '@/services/request'

export const ApiLogin = async (
  user: string,
  password: string,
  verifyCode?: string,
  uuid?: string
) => {
  return await ApiPost('/user/login', { user, pwd: password, verifyCode, uuid })
}

export const ApiRefreshVerifyCode = async (uuid: string) => {
  return (await ApiGet(`/user/${uuid}`)).data
}

export const ApiGetVerifyCode = async (phone: string) => {
  return (await ApiGet(`/user/register/${phone}`)).data
}

export const ApiGetUserInfo = async () => {
  return (await ApiGet('/user/profile')).data
}

export const ApiGetUserInfoList = async (prefix: string) => {
  return (await ApiGet('/user/info', { prefix })).data
}

export const ApiRegister = async (
  code: number,
  user: string,
  phone: string,
  pwd1: string,
  pwd2: string
) => {
  return (
    await ApiPost('/user/register', {
      user,
      phone,
      pwd1,
      pwd2,
      code
    })
  ).data
}
